<?php

use common\lib\defaultHtml;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = Yii::t('app', 'Queues');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="queues-index">
    <div class="opration">
        <div class="btn-group">
            <a href="<?=$baseurl.'?find=all'?>" class="btn btn-sm <?=$find == 'all' ? 'btn-info' : 'btn-default'?>">全部</a>
            <a href="<?=$baseurl.'?find=today'?>" class="btn btn-sm <?=$find == 'today' ? 'btn-info' : 'btn-default'?>">今日</a>
            <a href="<?=$baseurl.'?find=yesterday'?>" class="btn btn-sm <?=$find == 'yesterday' ? 'btn-info' : 'btn-default'?>">昨日</a>
            <a href="<?=$baseurl.'?find=thisweek'?>" class="btn btn-sm <?=$find == 'thisweek' ? 'btn-info' : 'btn-default'?>">本周</a>
            <a href="<?=$baseurl.'?find=lastweek'?>" class="btn btn-sm <?=$find == 'lastweek' ? 'btn-info' : 'btn-default'?>">上周</a>
            <a href="<?=$baseurl.'?find=thismonth'?>" class="btn btn-sm <?=$find == 'thismonth' ? 'btn-info' : 'btn-default'?>">本月</a>
            <a href="<?=$baseurl.'?find=lastmonth'?>" class="btn btn-sm <?=$find == 'lastmonth' ? 'btn-info' : 'btn-default'?>">上月</a>
        </div>
        <div class="input-group input-group-sm searchbox">
            <form name="searchForm" id="searchForm" action="" method="GET" class="form-inline">
                <div class="form-group"><input type="text" name="start" id="start" placeholder="开始日期" value="<?=$start?>" class="form-control input-sm" /></div>
                <div class="form-group"><input type="text" name="end" id="end" placeholder="结束日期" value="<?=$end?>" class="form-control input-sm" /></div>
                <button type="submit" class="btn btn-sm btn-info" href="javascript:void(0);"> <i class="fa fa-search"></i> 筛 选 </button>
            </form>
        </div>
    </div>
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'columns' => [
//            ['class' => 'yii\grid\SerialColumn'],

            ['attribute' => 'queueId', 'value' => function($model){return empty($model->queueId) ? '' : $model->queueId;}],
            ['attribute' => 'queueKey', 'value' => function($model){return empty($model->queueKey) ? '' : $model->queueKey;}],
            ['attribute' => 'realName', 'value' => function($model){return empty($model->realName) ? '' : $model->realName;}],
            ['attribute' => 'idCardNo', 'value' => function($model){return empty($model->idCardNo) ? '' : $model->idCardNo;}],
            ['attribute' => 'queueNo', 'value' => function($model){return empty($model->queueNo) ? '' : $model->queueNo;}],
            ['attribute' => 'queueNumber', 'value' => function($model){return $model->queueNumber;}],
            ['attribute' => 'inData', 'value' => function($model){return empty($model->inData) ? '' : $model->inData;}],
            ['attribute' => 'status', 'value' => function($model){
                switch($model->status){
                    case 1:return '排队成功';break;
                    case 2:return '核销成功';break;
                    case 3:return '已过期';break;
                    default:return '未知状态';break;
                } 
            }],
            ['attribute' => 'call', 'value' => function($model){
                switch($model->call){
                    case 1:return '等待叫号';break;
                    case 2:return '已叫号';break;
                    case 3:return '已过号';break;
                    default:return '未知状态';break;
                } 
            }],
            ['attribute' => 'ctime', 'value' => function($model){return empty($model->ctime) ? '' : date('Y-m-d H:i:s', $model->ctime);}],
            [
                'class' => 'yii\grid\ActionColumn',
                'header' => '<div class="text-center">操作</div>',
                'template' => '<div class="btn-group">{view}</div>',
                'buttons' => [
                    'view' => function ($url, $model, $key) {return defaultHtml::a('<span class="fa fa-eye"></span> 详情', $url, ['title' => '查看详情', 'class' => 'btn btn-xs  btn-success']);},
                ],
                'headerOptions' => ['width' => '120'],
            ],
        ],
    ]); ?>


</div>
